home *** CD-ROM | disk | FTP | other *** search
/ Mixa 155: Dogs / MIXA 155: Dogs.iso / pc / Viewer / BROWSER(W) / フィルタ / PDF / LIB / gs_init.ps < prev    next >
Encoding:
Text File  |  2002-10-29  |  57.7 KB  |  1,806 lines

  1. %    Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile: gs_init.ps,v $ $Revision: 1.20 $
  6. % Initialization file for the interpreter.
  7. % When this is run, systemdict is still writable.
  8.  
  9. % Comment lines of the form
  10. %    %% Replace <n> <file(s)>
  11. % indicate places where the next <n> lines should be replaced by
  12. % the contents of <file(s)>, when creating a single merged init file.
  13.  
  14. % The interpreter can call out to PostScript code.  All procedures
  15. % called in this way, and no other procedures defined in these
  16. % initialization files, have names that begin with %, e.g.,
  17. % (%Type1BuildChar) cvn.
  18.  
  19. % Check the interpreter revision.  NOTE: the interpreter code requires
  20. % that the first non-comment token in this file be an integer.
  21. 700
  22. dup revision ne
  23.  { (gs: Interpreter revision \() print revision 10 string cvs print
  24.    (\) does not match gs_init.ps revision \() print 10 string cvs print
  25.    (\).\n) print flush null 1 .quit
  26.  }
  27. if pop
  28.  
  29. % Acquire userdict, and set its length if necessary.
  30. /userdict where
  31.  { pop userdict maxlength 0 eq }
  32.  { true }
  33. ifelse
  34. systemdict exch
  35.  {        % userdict wasn't already set up by iinit.c.
  36.    dup /userdict
  37.    currentdict dup 200 .setmaxlength        % userdict
  38.    .forceput            % userdict is local, systemdict is global
  39.  }
  40. if begin
  41.  
  42. % Define dummy local/global operators if needed.
  43. systemdict /.setglobal known
  44.  { true .setglobal
  45.  }
  46.  { /.setglobal { pop } bind def
  47.    /.currentglobal { false } bind def
  48.    /.gcheck { pop false } bind def
  49.  }
  50. ifelse
  51.  
  52. % Define .languagelevel if needed.
  53. systemdict /.languagelevel known not { /.languagelevel 1 def } if
  54.  
  55. % Optionally choose a default paper size other than U.S. letter.
  56. % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
  57.  
  58. % Turn on array packing for the rest of initialization.
  59. true setpacking
  60.  
  61. % Define the old MS-DOS EOF character as a no-op.
  62. % This is a hack to get around the absurd habit of MS-DOS editors
  63. % of adding an EOF character at the end of the file.
  64. <1a> cvn { } def
  65.  
  66. % Acquire the debugging flags.
  67. currentdict /DEBUG known   /DEBUG exch def
  68.   /VMDEBUG
  69.     DEBUG {{print mark
  70.             systemdict /level2dict known
  71.          { .currentglobal dup false .setglobal vmstatus
  72.            true .setglobal vmstatus 3 -1 roll pop
  73.            6 -2 roll pop .setglobal
  74.          }
  75.          { vmstatus 3 -1 roll pop
  76.          }
  77.         ifelse usertime 16#fffff and counttomark
  78.           { ( ) print (           ) cvs print }
  79.         repeat pop
  80.         ( ) print systemdict length (    ) cvs print
  81.         ( ) print countdictstack (  ) cvs print
  82.         ( <) print count (    ) cvs print (>\n) print flush
  83.       }}
  84.       {{pop
  85.       }}
  86.      ifelse
  87.   def
  88.  
  89. currentdict /BATCH known   /BATCH exch def
  90. currentdict /DELAYBIND known   /DELAYBIND exch def
  91. currentdict /DISKFONTS known   /DISKFONTS exch def
  92. currentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } if
  93. currentdict /ESTACKPRINT known   /ESTACKPRINT exch def
  94. currentdict /FAKEFONTS known   /FAKEFONTS exch def
  95. currentdict /FIXEDMEDIA known   /FIXEDMEDIA exch def
  96. currentdict /FIXEDRESOLUTION known   /FIXEDRESOLUTION exch def
  97. currentdict /LOCALFONTS known   /LOCALFONTS exch def
  98. currentdict /NOBIND known   /NOBIND exch def
  99. /.bind /bind load def
  100. NOBIND { /bind { } def } if
  101. currentdict /NOCACHE known   /NOCACHE exch def
  102. currentdict /NOCIE known   /NOCIE exch def
  103. currentdict /NODISPLAY known   not /DISPLAYING exch def
  104. currentdict /NOFONTMAP known   /NOFONTMAP exch def
  105. currentdict /NOFONTPATH known   /NOFONTPATH exch def
  106. currentdict /NOGC known   /NOGC exch def
  107. currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if
  108. currentdict /NOPAGEPROMPT known   /NOPAGEPROMPT exch def
  109. currentdict /NOPAUSE known   /NOPAUSE exch def
  110. currentdict /NOPLATFONTS known   /NOPLATFONTS exch def
  111. currentdict /NOPROMPT known   /NOPROMPT exch def
  112. % The default value of ORIENT1 is true, not false.
  113. currentdict /ORIENT1 known not { /ORIENT1 true def } if
  114. currentdict /OSTACKPRINT known   /OSTACKPRINT exch def
  115. currentdict /OUTPUTFILE known    % obsolete
  116.  { /OutputFile /OUTPUTFILE load def
  117.    currentdict /OUTPUTFILE .undef
  118.  } if
  119. currentdict /QUIET known   /QUIET exch def
  120. currentdict /SAFER known   /SAFER exch def
  121. currentdict /DELAYSAFER known   /DELAYSAFER exch def
  122. currentdict /SHORTERRORS known   /SHORTERRORS exch def
  123. currentdict /STRICT known   /STRICT exch def
  124. currentdict /TTYPAUSE known   /TTYPAUSE exch def
  125. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  126.  
  127. % Acquire environment variables.
  128. currentdict /DEVICE known not
  129.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  130.  
  131. (START) VMDEBUG
  132.  
  133. % Open the standard files, so they will be open at the outermost save level.
  134. (%stdin) (r) file pop
  135. (%stdout) (w) file pop
  136. (%stderr) (w) file pop
  137.  
  138. /.currentuserparams where {
  139.   pop mark
  140.     % The Adobe implementations appear to have very large maximum
  141.     % stack sizes.  This turns out to actually make a difference,
  142.     % since some badly-behaved files include extremely long procedures,
  143.     % or construct huge arrays on the operand stack.
  144.     % We reset the stack sizes now so that we don't have to worry
  145.     % about overflowing the (rather small) built-in stack sizes
  146.     % during initialization.
  147.   /MaxDictStack 500
  148.   /MaxExecStack 5000
  149.   /MaxOpStack 50000
  150.   .dicttomark .setuserparams
  151. } if
  152.  
  153. % Define a procedure for skipping over an unneeded section of code.
  154. % This avoids allocating space for the skipped procedures.
  155. % We can't use readline, because that imposes a line length limit.
  156. /.skipeof    % <string> .skipeof -
  157.  { currentfile exch 1 exch .subfiledecode flushfile
  158.  } .bind def
  159.  
  160. % Define procedures to assist users who don't read the documentation.
  161. userdict begin
  162. /help
  163.  { (Enter PostScript commands.  '(filename) run' runs a file, 'quit' exits.\n)
  164.    print flush
  165.  } .bind def
  166. end
  167.  
  168. % Define =string, which is used by some PostScript programs even though
  169. % it isn't documented anywhere.
  170. % Put it in userdict so that each context can have its own copy.
  171. userdict /=string 256 string put
  172.  
  173. % Print the greeting.
  174.  
  175. /printgreeting
  176.  { mark
  177.    product (Ghostscript) search
  178.     { pop pop pop
  179.       (This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
  180.     }
  181.     { pop
  182.     }
  183.    ifelse
  184.    (\n) copyright
  185.    (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-)
  186.    revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-)
  187.    revisiondate 10000 idiv ( \()
  188.    revision 10 mod
  189.    revision 100 mod dup 0 ne { 10 idiv } { pop } ifelse (.)
  190.    revision 100 idiv ( )
  191.    product
  192.    counttomark
  193.     { (%stdout) (w) file exch 0 .writecvp
  194.     } repeat pop
  195.  } .bind def
  196.  
  197. QUIET not { printgreeting flush } if
  198.  
  199. % Define a special version of def for making operator procedures.
  200. /obind {    % <name> <proc> obind <name> <oper>
  201.   1 index exch .makeoperator
  202. } .bind def
  203. /odef {        % <name> <proc> odef -
  204.   1 index exch .makeoperator def
  205. } .bind def
  206.  
  207. % Define a special version of def for storing local objects into global
  208. % dictionaries.  Like .forceput, this exists only during initialization.
  209. /.forcedef {        % <key> <value> .forcedef -
  210.   currentdict 3 1 roll .forceput
  211. } .bind odef
  212.  
  213. % Define procedures for accessing variables in systemdict and userdict
  214. % regardless of the contents of the dictionary stack.
  215. /.systemvar {        % <name> .systemvar <value>
  216.   //systemdict exch get
  217. } .bind odef
  218. /.userdict {        % - .userdict <dict>
  219.   /userdict .systemvar
  220. } .bind odef
  221. /.uservar {        % <name> .uservar <value>
  222.   .userdict exch get
  223. } .bind odef
  224.  
  225. % If we're delaying binding, remember everything that needs to be bound later.
  226. DELAYBIND NOBIND not and
  227.  { .currentglobal false .setglobal
  228.    systemdict /.delaybind 1500 array .forceput
  229.    .setglobal
  230.    userdict /.delaycount 0 put
  231.     % When we've done the delayed bind, we want to stop saving.
  232.     % Detect this by the disappearance of .delaybind.
  233.    /bind
  234.     { /.delaybind .systemvar dup length 0 ne
  235.        { .delaycount 2 index put
  236.          .userdict /.delaycount .delaycount 1 add put
  237.        }
  238.        { pop .bind
  239.        }
  240.       ifelse
  241.     } .bind def
  242.  } if
  243.  
  244. %**************** BACKWARD COMPATIBILITY
  245. /hwsizedict mark /HWSize null .dicttomark readonly def
  246. /copyscanlines {        % <device> <y> <string> copyscanlines <substr>
  247.   0 3 1 roll 3 index //hwsizedict .getdeviceparams
  248.   exch pop exch pop aload pop 3 2 roll
  249.   0 exch null exch .getbitsrect exch pop
  250. } bind odef
  251. currentdict /hwsizedict .undef
  252. /getdeviceprops
  253.  { null .getdeviceparams
  254.  } bind odef
  255. /.putdeviceprops
  256.  { null true counttomark 1 add 3 roll .putdeviceparams
  257.    dup type /booleantype ne
  258.     { dup mark eq { /unknown /rangecheck } if
  259.       counttomark 4 add 1 roll cleartomark pop pop pop
  260.       /.putdeviceprops load exch signalerror
  261.     }
  262.    if
  263.  } bind odef
  264. /max { .max } bind def
  265. /min { .min } bind def
  266. /.currentfilladjust { .currentfilladjust2 pop } bind odef
  267. /.setfilladjust { dup .setfilladjust2 } bind odef
  268. /unread /.unread load def
  269. /.writecvs { 0 .writecvp } bind odef
  270.  
  271. % Define predefined procedures substituting for operators,
  272. % in alphabetical order.
  273.  
  274. userdict /#copies 1 put
  275. % Adobe implementations don't accept /[ or /], so we don't either.
  276. ([) cvn
  277.     /mark load def
  278. (]) cvn
  279.     {counttomark array astore exch pop} odef
  280. % .beginpage is redefined if setpagedevice is present.
  281. /.beginpage { } odef
  282. % In LanguageLevel 3, copypage erases the page.
  283. /copypage {
  284.     .languagelevel 3 ge
  285.     dup { 0 } { 1 } ifelse .endpage {
  286.       .currentnumcopies 1 index .outputpage
  287.       (>>copypage, press <return> to continue<<\n) .confirm
  288.       dup { erasepage } if
  289.     } if pop .beginpage
  290. } odef
  291. /currentmatrix {
  292.     .currentmatrix 6 index astore pop
  293. } odef
  294. % .currentnumcopies is redefined in Level 2.
  295. /.currentnumcopies { #copies } odef
  296. /setcolorscreen where { pop        % not in all Level 1 configurations
  297.    /currentcolorscreen
  298.     { .currenthalftone
  299.        { { 60 exch 0 exch 3 copy 6 copy }    % halftone - not possible
  300.          { 3 copy 6 copy }            % screen
  301.          { }                % colorscreen
  302.        }
  303.       exch get exec
  304.     } odef
  305. } if
  306. /currentscreen
  307.     { .currenthalftone
  308.        { { 60 exch 0 exch }            % halftone - not possible
  309.          { }                % screen
  310.          { 12 3 roll 9 { pop } repeat }    % colorscreen
  311.        }
  312.       exch get exec
  313.     } odef
  314. /.echo /echo load def
  315. userdict /.echo.mode true put
  316. /echo    {dup /.echo.mode exch store .echo} odef
  317. /eexec {
  318.     % Rebind .currentresourcefile if it is the source for the eexec.
  319.   dup 55665 //filterdict /eexecDecode get exec
  320.   cvx exch .currentresourcefile eq
  321.   //systemdict begin { {exec} .execasresource } { exec } ifelse
  322.     % Only pop systemdict if it is still the top element,
  323.     % because this is apparently what Adobe interpreters do.
  324.   currentdict //systemdict eq { end } if
  325. } odef
  326. % .endpage is redefined if setpagedevice is present.
  327. /.endpage { 2 ne } odef
  328. % erasepage mustn't use gsave/grestore, because we call it before
  329. % the graphics state stack has been fully initialized.
  330. /erasepage
  331.     { /currentcolor where
  332.        { pop currentcolor currentcolorspace { setcolorspace setcolor } }
  333.        { /currentcmykcolor where
  334.           { pop currentcmykcolor { setcmykcolor } }
  335.           { currentrgbcolor { setrgbcolor } }
  336.          ifelse
  337.        }
  338.       ifelse 1 setgray .fillpage exec
  339.     } odef
  340. % To satisfy the Genoa FTS, executive must be a procedure, not an operator.
  341. /executive
  342.     { { prompt
  343.          { (%statementedit) (r) file } stopped
  344.          { pop pop $error /errorname get /undefinedfilename eq
  345.         { .clearerror exit } if        % EOF
  346.            handleerror null        % ioerror??
  347.          }
  348.         if
  349.         cvx { .runexec } execute
  350.       } loop
  351.     } bind def
  352. /filter
  353.     { //filterdict 1 index .knownget
  354.        { exch pop exec }
  355.        { /filter load /undefined signalerror }
  356.       ifelse
  357.     } odef
  358. /handleerror
  359.     { /errordict .systemvar /handleerror get exec } bind def
  360. /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
  361. /identmatrix
  362.     { dup 0 //identmatrix putinterval } odef
  363. /languagelevel 1 def        % gs_lev2.ps may change this
  364. /makeimagedevice { false makewordimagedevice } odef
  365. /matrix    { 6 array identmatrix } odef
  366. /pathbbox
  367.     { false .pathbbox
  368.     } odef
  369. % .promptmsg is redefined if the interpreter includes readline support.
  370. /.promptmsg {
  371.     (GS) print
  372.     count 0 ne { (<) print count =only } if
  373.     (>) print flush
  374. } bind def
  375. /prompt    { flush flushpage NOPROMPT not { .promptmsg } if } bind def
  376. /pstack    { 0 1 count 3 sub { index == } for } bind def
  377. /putdeviceprops
  378.     { .putdeviceprops { erasepage } if } odef
  379. /quit    { /quit load 0 .quit } odef
  380. /run    { dup type /filetype ne { (r) file } if
  381.         % We must close the file when execution terminates,
  382.         % regardless of the state of the stack,
  383.         % and then propagate an error, if any.
  384.       cvx .runexec
  385.     } odef
  386. % Execute a file.
  387. % Level 2 uses 2 .stop to clear the e-stack for a successful startjob:
  388. % we detect that here, since we need to handle this even if we start out
  389. % without job control in effect.
  390. %
  391. % What we push on the e-stack is the following to be executed in this order:
  392. %    <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2
  393. /.runexec1 {        % <file|fileproc> .runexec1 -
  394.   dup type /filetype ne { cvx exec } if
  395.   cvx null 2 .stopped
  396.     % If we got back here from a startjob, just keep going.
  397.     % startjob replaces the null on the o-stack with a procedure
  398.     % to be executed when we get back here.
  399.   dup null ne { exec true } { pop false } ifelse
  400. } bind def
  401. /.runexec2 {        % <continue> <file|fileproc> .runexec2 -
  402.   exch {
  403.     .runexec
  404.   } {
  405.     dup type /filetype ne { cvx exec } if
  406.     closefile
  407.   } ifelse
  408. } bind def
  409. /.runexec {        % <file|fileproc> .runexec -
  410.   cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn
  411. } bind def
  412. % The following is only for compatibility with Adobe interpreters.
  413. /setdash {
  414.     1 index length 11 gt { /setdash load /limitcheck signalerror } if
  415.     //setdash
  416. } odef
  417. /setdevice
  418.     { .setdevice { erasepage } if } odef
  419. /setlinecap {
  420.     dup 2 gt { /setlinecap load /rangecheck signalerror } if
  421.     .setlinecap
  422. } odef
  423. /setlinejoin {
  424.     dup 2 gt { /setlinejoin load /rangecheck signalerror } if
  425.     .setlinejoin
  426. } odef
  427. /setmatrix {
  428.     dup aload pop .setmatrix pop
  429. } odef
  430. /showpage {
  431.     0 .endpage .doneshowpage {
  432.       .currentnumcopies true .outputpage
  433.       (>>showpage, press <return> to continue<<\n) .confirm
  434.       erasepage
  435.     } if initgraphics .beginpage
  436. } odef
  437. % Code output by Adobe Illustrator relies on the fact that
  438. % `stack' is a procedure, not an operator!!!
  439. /stack    { 0 1 count 3 sub { index = } for } bind def
  440. /start    { BATCH { null 0 .quit } { executive } ifelse } def
  441. % Internal uses of stopped that aren't going to do a stop if an error occurs
  442. % should use .internalstopped to avoid setting newerror et al.
  443. /.internalstopped { null 1 .stopped null ne } bind def
  444. /store {    % Don't alter operands before completing.
  445.     1 index where { 2 index 2 index put pop pop } { def } ifelse
  446. } odef
  447. /.typenames mark .typenames counttomark packedarray exch pop def
  448. /type {
  449.     //.typenames .type
  450. } odef
  451. currentdict /.typenames .undef
  452. % When running in Level 1 mode, this interpreter is supposed to be
  453. % compatible with PostScript "version" 54.0 (I think).
  454. /version (54.0) readonly def
  455. /.wheredict 10 dict def
  456. /.where /where load def
  457. /where {
  458.     //.wheredict 1 index .knownget { exec } { .where } ifelse
  459. } odef
  460.  
  461. % internaldict is defined in systemdict, but the dictionary is allocated
  462. % in local VM.  However, the procedure must be global, since it is an
  463. % "operator" and must be bind-able into global procedures.
  464. % We make a procedure for creating it, since we must create a new one
  465. % for each context with private local VM.
  466. /.makeinternaldict {
  467.   .currentglobal true .setglobal
  468.     [ /dup .systemvar 1183615869 /eq .systemvar
  469.     [ /pop .systemvar null ] cvx
  470.     false .setglobal
  471.     dup 1 10 dict .forceput    % proc is global, dict is local
  472.     true .setglobal
  473.     [ /internaldict /cvx .systemvar /invalidaccess /signalerror cvx ] cvx
  474.       /ifelse .systemvar
  475.     ] cvx executeonly
  476.   exch .setglobal
  477. } odef
  478. systemdict /internaldict dup .makeinternaldict .makeoperator
  479. .forceput        % proc is local, systemdict is global
  480. % Move superexec to internaldict if superexec is defined.
  481. currentdict /superexec .knownget {
  482.   1183615869 internaldict /superexec 3 -1 roll put
  483.   currentdict /superexec .undef
  484. } if
  485.  
  486. % Define some additional built-in procedures (beyond the ones defined by
  487. % the PostScript Language Reference Manual).
  488. % Warning: these are not guaranteed to stay the same from one release
  489. % to the next!
  490. /concatstrings
  491.     { exch dup length 2 index length add string    % str2 str1 new
  492.       dup dup 4 2 roll copy        % str2 new new new1
  493.       length 4 -1 roll putinterval
  494.     } bind def
  495. /copyarray
  496.     { dup length array copy } bind def
  497. % Copy a dictionary per the Level 2 spec even in Level 1.
  498. /.copydict        % <fromdict> <todict> .copydict <todict>
  499.     { dup 3 -1 roll { put dup } forall pop } bind def
  500. /copystring
  501.     { dup length string copy } bind def
  502. /findlibfile {
  503.     .libfile { dup .filename pop exch true } { false } ifelse
  504. } odef
  505. /.growdictlength    % get size for growing a dictionary
  506.     { length 3 mul 2 idiv 1 add
  507.     } bind def
  508. /.growdict        % grow a dictionary
  509.     { dup .growdictlength .setmaxlength
  510.     } bind def
  511. /.growput        % put, grow the dictionary if needed
  512.     { 2 index length 3 index maxlength eq
  513.        { 3 copy pop known not { 2 index .growdict } if
  514.        } if
  515.       put
  516.     } bind def
  517. % .localvmarray may be an operator: see zsysvm.c.
  518. /.localvmarray where {
  519.   pop
  520. } {
  521.   /.localvmarray {
  522.     .currentglobal false .setglobal
  523.     exch array exch .setglobal
  524.   } bind def
  525. } ifelse
  526. /.localvmdict where {
  527.   pop
  528. } {
  529.   /.localvmdict {
  530.     .currentglobal false .setglobal
  531.     exch dict exch .setglobal
  532.   } bind def
  533. } ifelse
  534. /.packtomark
  535.     { counttomark packedarray exch pop } bind def
  536. /ppstack
  537.     { 0 1 count 3 sub { index === } for } bind def
  538. /runlibfile
  539.     {        % We don't want to bind 'run' into this procedure,
  540.             % since run may get redefined.
  541.       findlibfile
  542.        { exch pop /run .systemvar exec }
  543.        { /undefinedfilename signalerror }
  544.       ifelse
  545.     } bind def
  546. /selectdevice
  547.     { finddevice setdevice .setdefaultscreen } bind def
  548. /signalerror        % <object> <errorname> signalerror -
  549.     { /errordict .systemvar exch get exec } bind def
  550.  
  551. % Define the =[only] procedures.  Also define =print,
  552. % which is used by some PostScript programs even though
  553. % it isn't documented anywhere.
  554. /write=only {
  555.     .writecvs
  556. } bind def
  557. /write= {
  558.     1 index exch write=only (\n) writestring
  559. } bind def
  560. /=only    { (%stdout) (w) file exch write=only } bind def
  561. /=    { =only (\n) print } bind def
  562. /=print    /=only load def
  563. % Temporarily define == as = for the sake of runlibfile0.
  564. /== /= load def
  565.  
  566. % The following procedures are documented.
  567. /copydevice {        % <device> copydevice <newdevice>
  568.   false .copydevice2
  569. } odef
  570. /finddevice {        % <devicename> finddevice <device>
  571.   /devicedict .systemvar exch get
  572.   dup 1 get null eq {
  573.         % This is the first request for this type of device.
  574.         % Create a default instance now.
  575.         % Stack: [proto null]
  576.     .currentglobal true .setglobal exch
  577.     dup dup 0 get copydevice 1 exch put
  578.     exch .setglobal
  579.   } if 1 get
  580. } bind def
  581. /findprotodevice {    % <devicename> findprotodevice <protodevice>
  582.   /devicedict .systemvar exch get 0 get
  583. } bind def
  584.  
  585. % Run a resource file.  This allows us to distinguish resource objects
  586. % from objects coming from input files.
  587. userdict /.currentresourcefile null put
  588. /.execasresource {    % <file> <proc|runfile> .execasresource -
  589.   /stopped .systemvar
  590.   /.currentresourcefile .uservar
  591.         % Stack: file proc -stopped- currfile
  592.   .userdict /.currentresourcefile 5 index cvlit put
  593.   2 .execn        % stopped <file>
  594.   .userdict /.currentresourcefile 3 -1 roll put
  595.   { stop } if
  596. } bind def
  597. /.runresource {        % <file> .runresource -
  598.   { /run .systemvar exec } .execasresource
  599. } bind def
  600.  
  601. % Define procedures for getting and setting the current device resolution.
  602.  
  603. /gsgetdeviceprop    % <device> <propname> gsgetdeviceprop <value>
  604.  { 2 copy mark exch null .dicttomark .getdeviceparams
  605.    dup mark eq        % if true, not found
  606.     { pop dup /undefined signalerror }
  607.     { 5 1 roll pop pop pop pop }
  608.    ifelse
  609.  } bind def
  610. /gscurrentresolution    % - gscurrentresolution <[xres yres]>
  611.  { currentdevice /HWResolution gsgetdeviceprop
  612.  } bind def
  613. /gssetresolution    % <[xres yres]> gssetresolution -
  614.  { 2 array astore mark exch /HWResolution exch
  615.    currentdevice copydevice putdeviceprops setdevice
  616.  } bind def
  617.  
  618. % Define auxiliary procedures needed for the above.
  619. /shellarguments        % -> shell_arguments true (or) false
  620.     { /ARGUMENTS where
  621.        { /ARGUMENTS get dup type /arraytype eq
  622.           { aload pop /ARGUMENTS null store true }
  623.           { pop false }
  624.          ifelse }
  625.        { false } ifelse
  626.     } bind def
  627. /.confirm {
  628.   DISPLAYING NOPAUSE not TTYPAUSE or and {
  629.     % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
  630.     % and wait for the user to type something.
  631.     % If the user just types a newline, flush it.
  632.     NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
  633.     .confirmread
  634.   } {
  635.     pop
  636.   } ifelse
  637. } bind def
  638. /.confirmread {
  639.   TTYPAUSE {
  640.     (/dev/tty) (r) file dup read pop pop closefile
  641.   } {
  642.     .echo.mode false echo
  643.     (%stdin) (r) file dup read {
  644.       dup (\n) 0 get eq { pop pop } { unread } ifelse
  645.     } {
  646.       pop
  647.     } ifelse echo
  648.   } ifelse
  649. } bind def
  650.  
  651. % Define the procedure used by .runfile, .runstdin and .runstring
  652. % for executing user input.
  653. % This is called with a procedure or executable file on the operand stack.
  654. /.execute {        % <obj> .execute <stopped>
  655.   stopped $error /newerror get and
  656.    { handleerror flush true } { false } ifelse
  657. } bind def
  658. /execute {        % <obj> execute -
  659.   .execute pop
  660. } odef
  661. % Define an execute analogue of runlibfile0.
  662. /execute0 {        % <obj> execute0 -
  663.   .execute { /execute0 cvx 1 .quit } if
  664. } bind def
  665. % Define the procedure that the C code uses for running files
  666. % named on the command line.
  667. /.runfile {
  668.   { runlibfile } execute0
  669. } def
  670. % Define the procedure that the C code uses for running piped input.
  671. % We don't use the obvious { (%stdin) run }, because we want the file to be
  672. % reopened if a startjob does a restore.
  673. /.runstdin {
  674.   { { (%stdin) (r) file cvx } .runexec } execute0
  675. } bind def
  676. % Define the procedure that the C code uses for running commands
  677. % given on the command line with -c.  We turn the string into a file so that
  678. % .runexec can do the right thing with a startjob.
  679. /.runstring {
  680.   .currentglobal exch true .setglobal
  681.   0 () .subfiledecode
  682.   exch .setglobal cvx { .runexec } execute0
  683. } bind def
  684. % Define the procedure that the C code uses to set up for executing
  685. % a string that may be received in pieces.
  686. /.runstringbegin {
  687.   .currentglobal true .setglobal
  688.   { .needinput } bind 0 () .subfiledecode
  689.   exch .setglobal cvx .runexec
  690. } bind def
  691.  
  692. % Define a special version of runlibfile that aborts on errors.
  693. /runlibfile0
  694.     { cvlit dup /.currentfilename exch def
  695.        { findlibfile not { stop } if }
  696.       stopped
  697.        { (Can't find \(or open\) initialization file ) print
  698.          .currentfilename == flush /runlibfile0 cvx 1 .quit
  699.        } if
  700.       exch pop cvx stopped
  701.        { (While reading ) print .currentfilename print (:\n) print flush
  702.          handleerror /runlibfile0 1 .quit
  703.        } if
  704.     } bind def
  705. % Temporarily substitute it for the real runlibfile.
  706. /.runlibfile /runlibfile load def
  707. /runlibfile /runlibfile0 load def
  708.  
  709. % Create the error handling machinery.
  710. % Define the standard error handlers.
  711. % The interpreter has created the ErrorNames array.
  712. /.unstoppederrorhandler    % <command> <errorname> .unstoppederrorhandler -
  713.  {    % This is the handler that gets used for recursive errors,
  714.     % or errors outside the scope of a 'stopped'.
  715.    2 copy SHORTERRORS
  716.     { (%%[ Error: ) print =only flush
  717.       (; OffendingCommand: ) print =only ( ]%%) =
  718.     }
  719.     { (Unrecoverable error: ) print =only flush
  720.       ( in ) print = flush
  721.       count 2 gt
  722.        { (Operand stack:\n  ) print
  723.      2 1 count 3 sub { (  ) print index =only flush } for
  724.      () = flush
  725.        } if
  726.     }
  727.    ifelse
  728.    -1 0 1 //ErrorNames length 1 sub
  729.     { dup //ErrorNames exch get 3 index eq
  730.        { not exch pop exit } { pop } ifelse
  731.     }
  732.    for exch pop .quit
  733.  } bind def
  734. /.errorhandler        % <command> <errorname> .errorhandler -
  735.   {        % Detect an internal 'stopped'.
  736.     1 .instopped { null eq { pop pop stop } if } if
  737.     $error /.inerror get 1 .instopped { pop } { pop true } ifelse
  738.      { .unstoppederrorhandler
  739.      } if    % detect error recursion
  740.     $error /globalmode .currentglobal false .setglobal put
  741.     $error /.inerror true put
  742.     $error /newerror true put
  743.     $error exch /errorname exch put
  744.     $error exch /command exch put
  745.     $error /recordstacks get $error /errorname get /VMerror ne and
  746.      {        % Attempt to store the stack contents atomically.
  747.        count array astore dup $error /ostack 4 -1 roll
  748.        countexecstack array execstack $error /estack 3 -1 roll
  749.        countdictstack array dictstack $error /dstack 3 -1 roll
  750.        put put put aload pop
  751.      }
  752.      { $error /dstack .undef
  753.        $error /estack .undef
  754.        $error /ostack .undef
  755.      }
  756.     ifelse
  757.     $error /position currentfile status
  758.      { currentfile { fileposition } .internalstopped { pop null } if
  759.      }
  760.      {        % If this was a scanner error, the file is no longer current,
  761.         % but the command holds the file, which may still be open.
  762.        $error /command get dup type /filetype eq
  763.         { { fileposition } .internalstopped { pop null } if }
  764.         { pop null }
  765.        ifelse
  766.      }
  767.     ifelse put
  768.         % During initialization, we don't reset the allocation
  769.         % mode on errors.
  770.     $error /globalmode get $error /.nosetlocal get and .setglobal
  771.     $error /.inerror false put
  772.     stop
  773.   } bind def
  774. % Define the standard handleerror.  We break out the printing procedure
  775. % (.printerror) so that it can be extended for binary output
  776. % if the Level 2 facilities are present.
  777.   /.printerror
  778.    { $error begin
  779.        /command load errorname SHORTERRORS
  780.     { (%%[ Error: ) print =only flush
  781.       (; OffendingCommand: ) print =only
  782.       errorinfo dup null eq {
  783.         pop
  784.       } {
  785.         (;\nErrorInfo:) print
  786.         dup type /arraytype eq
  787.           { { ( ) print =only } forall }
  788.           { ( ) print =only }
  789.         ifelse
  790.       } ifelse
  791.           ( ]%%) = flush
  792.     }
  793.     { (Error: ) print ==only flush
  794.       ( in ) print ==only flush
  795.       errorinfo dup null eq {
  796.         pop
  797.       } {
  798.         (\nAdditional information: ) print ==only flush
  799.       } ifelse
  800.       .printerror_long
  801.     }
  802.        ifelse
  803.        .clearerror
  804.      end
  805.      flush
  806.     } bind def     
  807.   /.printerror_long            % long error printout,
  808.                     % $error is on the dict stack
  809.    {    % Push the (anonymous) stack printing procedure.
  810.     %  <heading> <==flag> <override-name> <stackname> proc
  811.        {
  812.      currentdict exch .knownget    % stackname defined in $error?
  813.      {
  814.        4 1 roll            % stack: <stack> <head> <==flag> <over>
  815.        errordict exch .knownget    % overridename defined?
  816.        { 
  817.          exch pop exch pop exec    % call override with <stack>
  818.        }
  819.        { 
  820.          exch print exch        % print heading. stack <==flag> <stack>
  821.          1 index not { () = } if
  822.          { 1 index { (\n    ) } { (   ) } ifelse print
  823.            dup type /dicttype eq
  824.            {
  825.          (--dict:) print
  826.          dup rcheck {
  827.            dup length =only (/) print dup maxlength =only
  828.            dup wcheck not { ((ro)) print } if
  829.          } if
  830.          /gcheck where {
  831.            pop gcheck { ((G)) } { ((L)) } ifelse print
  832.          } {
  833.            pop
  834.          } ifelse (--) print
  835.            }
  836.            {
  837.          dup type /stringtype eq 2 index or
  838.          { ==only } { =only } ifelse
  839.            } ifelse
  840.          } forall
  841.          pop
  842.        }
  843.        ifelse            % overridden
  844.      }
  845.      { pop pop pop
  846.      }
  847.      ifelse                % stack known
  848.        }
  849.  
  850.        (\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec
  851.        (\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec
  852.        (\nBacktrace:) true /.printbacktrace /backtrace 4 index exec
  853.        (\nDictionary stack:) false /.printdstack /dstack 4 index exec
  854.        () =
  855.        pop    % printing procedure
  856.  
  857.        errorname /VMerror eq
  858.     { (VM status:) print mark vmstatus
  859.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  860.       cleartomark () =
  861.     } if
  862.  
  863.        .languagelevel 2 ge
  864.     { (Current allocation mode is ) print
  865.       globalmode { (global\n) } { (local\n) } ifelse print
  866.     } if
  867.  
  868.        .oserrno dup 0 ne
  869.     { (Last OS error: ) print
  870.       errorname /VMerror ne
  871.        { dup .oserrorstring { = pop } { = } ifelse }
  872.        { = }
  873.       ifelse
  874.     }
  875.     { pop
  876.     }
  877.        ifelse
  878.  
  879.        position null ne
  880.     { (Current file position is ) print position = }
  881.        if
  882.  
  883.    } bind def
  884. % Define a procedure for clearing the error indication.
  885. /.clearerror
  886.  { $error /newerror false put
  887.    $error /errorname null put
  888.    $error /errorinfo null put
  889.    0 .setoserrno
  890.  } bind def
  891.  
  892. % Define $error.  This must be in local VM.
  893. .currentglobal false .setglobal
  894. /$error 40 dict .forcedef    % $error is local, systemdict is global
  895.         % newerror, errorname, command, errorinfo,
  896.         % ostack, estack, dstack, recordstacks,
  897.         % binary, globalmode,
  898.         % .inerror, .nosetlocal, position,
  899.         % plus extra space for badly designed error handers.
  900. $error begin
  901.   /newerror false def
  902.   /recordstacks true def
  903.   /binary false def
  904.   /globalmode .currentglobal def
  905.   /.inerror false def
  906.   /.nosetlocal true def
  907.   /position null def
  908. end
  909. % Define errordict similarly.  It has one entry per error name,
  910. %   plus handleerror.  However, some astonishingly badly written PostScript
  911. %   files require it to have at least one empty slot.
  912. /errordict ErrorNames length 2 add dict
  913. .forcedef        % errordict is local, systemdict is global
  914. .setglobal        % contents of errordict are global
  915. errordict begin
  916.   ErrorNames
  917.    { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
  918.    } forall
  919. % The handlers for interrupt and timeout are special; there is no
  920. % 'current object', so they push their own name.
  921.    { /interrupt /timeout }
  922.    { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
  923.    } forall
  924. /handleerror
  925.  { /.printerror .systemvar exec
  926.  } bind def
  927. end
  928.  
  929. % Define the [write]==[only] procedures.
  930. /.dict 8 dict dup
  931. begin def
  932.   /.cvp {1 index exch 1 .writecvp} bind def
  933.   /.p {1 index exch writestring} bind def
  934.   /.p1 {2 index exch writestring} bind def
  935.   /.p2 {3 index exch writestring} bind def
  936.   /.print
  937.     { dup type .dict exch .knownget { exec } { .cvp } ifelse
  938.     } bind def
  939.   /arraytype
  940.     {dup rcheck
  941.       {() exch dup xcheck
  942.         {({) .p2
  943.          {exch .p1
  944.           1 index exch .print pop ( )} forall
  945.          (})}
  946.         {([) .p2
  947.          {exch .p1
  948.           1 index exch .print pop ( )} forall
  949.          (])}
  950.        ifelse exch pop .p}
  951.       {.cvp}
  952.      ifelse} bind def
  953.   /packedarraytype /arraytype load def
  954. {//.dict begin .print pop end}
  955.   bind
  956. end
  957.  
  958. /write==only exch def
  959. /write== {1 index exch write==only (\n) writestring} bind def
  960. /==only { (%stdout) (w) file exch write==only } bind def
  961. /== {==only (\n) print} bind def
  962.  
  963. % Define [write]===[only], an extension that prints dictionaries
  964. % in readable form and doesn't truncate strings.
  965. /.dict /write==only load 0 get dup length 2 add dict .copydict dup
  966. begin def
  967.   /dicttype
  968.     { dup rcheck
  969.        { (<< ) .p1
  970.           { 2 index 3 -1 roll .print pop ( ) .p1
  971.         1 index exch .print pop ( ) .p
  972.           }
  973.          forall (>>) .p
  974.        }
  975.        { .cvp
  976.        }
  977.       ifelse
  978.     } bind def
  979.   /stringtype
  980.     { 1 index exch 2 .writecvp
  981.     } bind def
  982.  
  983. {//.dict begin .print pop end}
  984.   bind
  985. end
  986.  
  987. /write===only exch def
  988. /write=== {1 index exch write===only (\n) writestring} bind def
  989. /===only { (%stdout) (w) file exch write===only } bind def
  990. /=== { ===only (\n) print } bind def
  991.  
  992. (END PROCS) VMDEBUG
  993.  
  994. % Define the font directory.
  995. /FontDirectory false .setglobal 100 dict true .setglobal
  996. .forcedef        % FontDirectory is local, systemdict is global
  997.  
  998. % Define the encoding dictionary.
  999. /EncodingDirectory 16 dict def    % enough for Level 2 + PDF standard encodings
  1000.  
  1001. % Define .findencoding.  (This is redefined in Level 2.)
  1002. /.findencoding
  1003.  { //EncodingDirectory exch get exec
  1004.  } bind def
  1005. /.defineencoding
  1006.  { //EncodingDirectory 3 1 roll put
  1007.  } bind def
  1008. % If we've got the composite font extensions, define findencoding.
  1009. % To satisfy the Genoa FTS, findencoding must be a procedure, not an operator.
  1010. /rootfont where { pop /findencoding { .findencoding } def } if
  1011.  
  1012. % Define .registerencoding.
  1013. % NOTE: the name registeredencodings is known to (initialized by and shared
  1014. % with) the interpreter.
  1015. /.registerencoding {    % <index> <array> .registerencoding -
  1016.     % Check that the array is indexable.
  1017.     % (It might still be a string, but then the .namestring will fail.)
  1018.   dup 0 0 getinterval pop
  1019.     % Check that all the elements of the array are names.
  1020.   dup { .namestring pop } forall
  1021.     % Do the store.
  1022.   //registeredencodings 2 index 2 index readonly put pop pop
  1023. } bind odef
  1024. systemdict /registeredencodings .undef
  1025.  
  1026. % Load StandardEncoding.
  1027. %% Replace 1 (gs_std_e.ps)
  1028. (gs_std_e.ps) dup runlibfile VMDEBUG
  1029.  
  1030. % Load ISOLatin1Encoding.
  1031. %% Replace 1 (gs_il1_e.ps)
  1032. (gs_il1_e.ps) dup runlibfile VMDEBUG
  1033.  
  1034. % Define stubs for the Symbol and Dingbats encodings.
  1035. % Note that the first element of the procedure must be the file name,
  1036. % since gs_lev2.ps extracts it to set up the Encoding resource category.
  1037.  
  1038.   /SymbolEncoding { /SymbolEncoding .findencoding } bind def
  1039. %% Replace 3 (gs_sym_e.ps)
  1040.   EncodingDirectory /SymbolEncoding
  1041.    { (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end }
  1042.   bind put
  1043.  
  1044.   /DingbatsEncoding { /DingbatsEncoding .findencoding } bind def
  1045. %% Replace 3 (gs_dbt_e.ps)
  1046.   EncodingDirectory /DingbatsEncoding
  1047.    { (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end }
  1048.   bind put
  1049.  
  1050. (END FONTDIR/ENCS) VMDEBUG
  1051.  
  1052. % Construct a dictionary of all available devices.
  1053. % These are (read-only) device prototypes that can't be
  1054. % installed or have their parameters changed.  For this reason,
  1055. % the value in the dictionary is actually a 2-element writable array,
  1056. % to allow us to create a default instance of the prototype on demand.
  1057.  
  1058.     % Loop until the .getdevice gets a rangecheck.
  1059. errordict /rangecheck 2 copy get
  1060. errordict /rangecheck { pop stop } put    % pop the command
  1061.   0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
  1062.   1 add dict  /devicedict 1 index def
  1063.   begin            % 2nd copy of count is on stack
  1064.    { dup .devicename exch
  1065.      dup wcheck { dup } { null } ifelse 2 array astore def
  1066.    } repeat
  1067.   end
  1068. put        % errordict /rangecheck
  1069. .clearerror
  1070. /devicenames devicedict { pop } forall devicedict length packedarray def
  1071.  
  1072. % Determine the default device.
  1073. /defaultdevice DISPLAYING
  1074.  { systemdict /DEVICE .knownget
  1075.     { devicedict 1 index known not
  1076.        { (Unknown device: ) print =
  1077.      flush /defaultdevice cvx 1 .quit
  1078.        }
  1079.       if
  1080.     }
  1081.     { 0 .getdevice .devicename
  1082.     }
  1083.    ifelse
  1084.  }
  1085.  { /nullpage
  1086.  }
  1087. ifelse
  1088. /.defaultdevicename 1 index def
  1089. finddevice    % make a copy
  1090. def
  1091. devicedict /Default devicedict .defaultdevicename get put
  1092.  
  1093. (END DEVS) VMDEBUG
  1094.  
  1095. % Define statusdict, for the benefit of programs
  1096. % that think they are running on a LaserWriter or similar printer.
  1097. %% Replace 1 (gs_statd.ps)
  1098. (gs_statd.ps) runlibfile
  1099.  
  1100. (END STATD) VMDEBUG
  1101.  
  1102. % Load the standard font environment.
  1103. %% Replace 1 (gs_fonts.ps)
  1104. (gs_fonts.ps) runlibfile
  1105.  
  1106. (END GS_FONTS) VMDEBUG
  1107.  
  1108. % Define the default halftone screen and BG/UCR functions now, so that
  1109. % it will bind in the original definitions of set[color]screen.
  1110. % We make this a procedure so we can call it again when switching devices.
  1111.  
  1112. % Use an ordered dither for low-resolution devices.
  1113. /.setloreshalftone {    % <dpi> .setloreshalftone -
  1114.     % The following 'ordered dither' spot function was contributed by
  1115.     % Gregg Townsend.  Thanks, Gregg!
  1116.    16.001 div 0            % not 16: avoids rounding problems
  1117.     { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  1118.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  1119.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  1120.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  1121.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  1122.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  1123.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  1124.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  1125.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  1126.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  1127.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  1128.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  1129.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  1130.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  1131.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  1132.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  1133.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  1134.      > exch get 256 div
  1135.     }
  1136.    bind
  1137.         % Use correct, per-plane screens for CMYK devices only.
  1138.    //systemdict /setcolorscreen known processcolors 4 eq and
  1139.     { 3 copy 6 copy //setcolorscreen }
  1140.     { //setscreen }
  1141.    ifelse
  1142. } bind def
  1143. /.setloresscreen {    % <dpi> .setloresscreen -
  1144.   .setloreshalftone
  1145.   0 array cvx settransfer    % Genoa CET won't accept a packed array!
  1146.   /setstrokeadjust where { pop true setstrokeadjust } if
  1147. } bind def
  1148. % Use a 45-degree spot screen for high-resolution devices.
  1149. /.sethireshalftone {    % <dpi> .sethireshalftone <doscreen>
  1150.     % According to information published by Hewlett-Packard,
  1151.     % they use a 60 line screen on 300 DPI printers and
  1152.     % an 85 line screen on 600 DPI printers.
  1153.     % However, we use a 106 line screen, which produces smoother-
  1154.     % looking shades but fewer of them (32 vs. 50).
  1155.     % 46 was suggested as a good frequency value for printers
  1156.     % between 200 and 400 DPI, so we use it for lower resolutions.
  1157.     % Imagesetters need even higher frequency screens.
  1158.    //systemdict /DITHERPPI known
  1159.     { DITHERPPI
  1160.     }
  1161.     { dup cvi 100 idiv 15 .min
  1162.        {null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150}
  1163.       exch get
  1164.      }
  1165.    ifelse
  1166.    1 index 4.01 div .min    % at least a 4x4 cell
  1167.    45
  1168.     % The following screen algorithm is used by permission of the author.
  1169.     { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos 
  1170.       1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  1171.     }
  1172.    bind
  1173.     % Determine whether we have lots of process colors.
  1174.     % If so, don't bother with color screening or gamma correction.
  1175.     % Also don't do gamma correction on very high-resolution devices.
  1176.     % (This should depend on dot gain, not resolution, but we don't
  1177.     % currently have a way to determine this.)
  1178.    currentdevice mark
  1179.      /RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0
  1180.    .dicttomark .getdeviceparams
  1181.    counttomark 2 idiv 1 sub { exch pop min } repeat
  1182.    exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll
  1183.     % Stack: doscreen dpi freq angle proc
  1184.     % Ghostscript currently doesn't use correct, per-plane halftones
  1185.     % unless setcolorscreen has been executed.  Since these are
  1186.     % computationally much more expensive than binary halftones,
  1187.     % we check to make sure they are really warranted, i.e., we have
  1188.     % a high-resolution CMYK device (i.e., not a display) with
  1189.     % fewer than 5 bits per plane (i.e., not a true-color device).
  1190.    4 -1 roll 150 ge
  1191.     { /setcolorscreen where
  1192.        { pop //systemdict /COLORSCREEN known
  1193.       { COLORSCREEN }
  1194.       { 3 index }
  1195.      ifelse
  1196.      dup false ne
  1197.       { 4 1 roll 3 copy 6 copy 13 -1 roll
  1198.     % For really high-quality screening on printers, we need to
  1199.     % give each plane its own screen angle.  Unfortunately,
  1200.     % this currently has very large space and time costs.
  1201.         true eq        % true => different angles,
  1202.                 % 0 => same angles
  1203.          { { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall
  1204.          }
  1205.         if //setcolorscreen
  1206.       }
  1207.       { pop //setscreen    % false => single binary screen
  1208.       }
  1209.      ifelse
  1210.        }
  1211.        { //setscreen        % setcolorscreen not known
  1212.        }
  1213.       ifelse
  1214.     }
  1215.     { //setscreen            % not high resolution
  1216.     }
  1217.    ifelse
  1218. } bind def
  1219. /.sethiresscreen {    % <dpi> .sethiresscreen -
  1220.   .sethireshalftone
  1221.             % Stack: doscreen
  1222.     {    % Set the transfer function to lighten up the grays.
  1223.     % We correct at the high end so that very light grays
  1224.     % don't disappear completely if they darken <1 screen pixel.
  1225.     % Parameter values closer to 1 are better for devices with
  1226.     % less dot spreading; lower values are better with more spreading.
  1227.     % The value 0.8 is a compromise that will probably please no one!
  1228.     %
  1229.     % Because of a bug in FrameMaker, we have to accept operands
  1230.     % outside the valid range of [0..1].
  1231.       { dup dup 0.0 gt exch 1.0 lt and
  1232.      { 0.8 exp dup dup 0.9375 gt exch 0.999 lt and    % > 15/16
  1233.         { .currentscreenlevels 1 sub    % tweak to avoid boundary
  1234.           1 exch div 1 exch sub .min
  1235.         }
  1236.        if
  1237.      }
  1238.     if
  1239.       }
  1240.     }
  1241.     {    % Set the transfer function to the identity.
  1242.       0 array cvx        % Genoa CET won't accept a packed array!
  1243.     }
  1244.    ifelse settransfer
  1245.    /setstrokeadjust where { pop false setstrokeadjust } if
  1246.     % Increase fill adjustment so that we effectively use Adobe's
  1247.     % any-part-of-pixel rule.
  1248.    0.5 .setfilladjust
  1249. } bind def
  1250. % Set the default screen and BG/UCR.
  1251. /.setdefaultbgucr {
  1252.   systemdict /setblackgeneration known {
  1253.     { pop 0 } dup setblackgeneration setundercolorremoval
  1254.   } if
  1255. } bind def
  1256. /.useloresscreen {    % - .useloresscreen <bool>
  1257.     % Compute min(|dpi x|,|dpi y|) as the definition of the resolution.
  1258.   72 72 matrix defaultmatrix dtransform abs exch abs .min
  1259.   dup 150 lt //systemdict /DITHERPPI known not and
  1260. } bind def
  1261.  
  1262. % The following implementation uses LL2 extensions, but only in stopped
  1263. % contexts so that with LL1, the .set??reshalftone will be used.
  1264. %
  1265. %    - .getdefaulthalftone <halftonedict> true    if default found
  1266. %                  false            
  1267. /.getdefaulthalftone {
  1268.   % try the device to see if it has a default halftone
  1269.   { currentdevice /HalftoneDefault gsgetdeviceprop } stopped
  1270.   { pop pop false }        % no device property
  1271.   { dup type /dicttype eq { true } { pop false } ifelse }
  1272.   ifelse
  1273.   % stack: <halftonedict> true    if default found
  1274.   %         false          not found
  1275.   dup not
  1276.   { % device did not provide a default, try Resource
  1277.     pop { /Default /Halftone /findresource .systemvar exec } stopped 
  1278.     { pop pop false } { true } ifelse
  1279.   }
  1280.   if
  1281. } bind def
  1282.  
  1283. /.setdefaulthalftone {
  1284.   .getdefaulthalftone 
  1285.   { sethalftone }
  1286.   { % default not found
  1287.     .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse
  1288.   }
  1289.   ifelse
  1290. } bind def
  1291.  
  1292. /.setdefaultscreen {
  1293.   .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse
  1294.   .setdefaultbgucr
  1295. } bind def
  1296.  
  1297. % Load the initialization files for optional features.
  1298. %% Replace 4 INITFILES
  1299. systemdict /INITFILES known
  1300.  { INITFILES { dup runlibfile VMDEBUG } forall
  1301.  }
  1302. if
  1303.  
  1304. % If Level 2 (or higher) functionality is implemented, enable it now.
  1305. /.setlanguagelevel where {
  1306.   pop 2 .setlanguagelevel
  1307.     % If the resource machinery is loaded, fix up some things now.
  1308.   /.fixresources where { pop .fixresources } if
  1309. } if
  1310. /ll3dict where {
  1311.   pop 3 .setlanguagelevel
  1312. } if
  1313.  
  1314. (END INITFILES) VMDEBUG
  1315.  
  1316. % Create a null font.  This is the initial font.
  1317. 8 dict dup begin
  1318.   /FontMatrix [ 1 0 0 1 0 0 ] readonly def
  1319.   /FontType 3 def
  1320.   /FontName () def
  1321.   /Encoding StandardEncoding def
  1322.   /FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ...
  1323.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  1324.   /PaintType 0 def        % shouldn't be needed!
  1325. end
  1326. /NullFont exch definefont setfont
  1327.  
  1328. % Define NullFont as the font.
  1329. /NullFont currentfont def
  1330.  
  1331. % Load initial fonts from FONTPATH directories, Fontmap file,
  1332. % and/or .getccfont as appropriate.
  1333. .loadinitialfonts
  1334.  
  1335. % Remove NullFont from FontDirectory, so it can't be accessed by mistake.
  1336. /undefinefont where {
  1337.   pop /NullFont undefinefont
  1338. } {
  1339.   FontDirectory /NullFont .undef
  1340. } ifelse
  1341.  
  1342. (END FONTS) VMDEBUG
  1343.  
  1344. % Restore the real definition of runlibfile.
  1345. /runlibfile /.runlibfile load def
  1346. currentdict /.runlibfile .undef
  1347.  
  1348. % Bind all the operators defined as procedures.
  1349. /.bindoperators        % binds operators in currentdict
  1350.  { % Temporarily disable the typecheck error.
  1351.    errordict /typecheck 2 copy get
  1352.    errordict /typecheck { pop } put    % pop the command
  1353.    currentdict
  1354.     { dup type /operatortype eq
  1355.        { % This might be a real operator, so bind might cause a typecheck,
  1356.      % but we've made the error a no-op temporarily.
  1357.      .bind        % do a real bind even if NOBIND is set
  1358.        }
  1359.       if pop pop
  1360.     } forall
  1361.    put
  1362.  } def
  1363. NOBIND DELAYBIND or not { .bindoperators } if
  1364.  
  1365. % Establish a default environment.
  1366.  
  1367. defaultdevice
  1368. % The following line used to skip setting of page size and resolution if
  1369. % NODISPLAY was selected.  We think this was only to save time and memory,
  1370. % and it is a bad idea because it prevents setting the resolution in this
  1371. % situation, which pstoedit (among other programs) relies on.
  1372. %DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
  1373. systemdict /DEVICEWIDTH known
  1374. systemdict /DEVICEHEIGHT known or
  1375. systemdict /DEVICEWIDTHPOINTS known or
  1376. systemdict /DEVICEHEIGHTPOINTS known or
  1377. systemdict /DEVICEXRESOLUTION known or
  1378. systemdict /DEVICEYRESOLUTION known or
  1379. systemdict /PAPERSIZE known or
  1380. not { (%END DEVICE) .skipeof } if
  1381. % Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE.
  1382. systemdict /PAPERSIZE known
  1383. systemdict /DEVICEWIDTH known not and
  1384. systemdict /DEVICEHEIGHT known not and
  1385. systemdict /DEVICEWIDTHPOINTS known not and
  1386. systemdict /DEVICEHEIGHTPOINTS known not and
  1387.  {    % Convert the paper size to device dimensions.
  1388.    true statusdict /.pagetypenames get
  1389.     { PAPERSIZE eq
  1390.        { PAPERSIZE load
  1391.          dup 0 get /DEVICEWIDTHPOINTS exch def
  1392.          1 get /DEVICEHEIGHTPOINTS exch def
  1393.          pop false exit
  1394.        }
  1395.       if
  1396.     }
  1397.    forall
  1398.     { (Unknown paper size: ) print PAPERSIZE ==only (.) =
  1399.     }
  1400.    if
  1401.  }
  1402. if
  1403. % Adjust the device parameters per the command line.
  1404. % It is possible to specify resolution, pixel size, and page size;
  1405. % since any two of these determine the third, conflicts are possible.
  1406. % We simply pass them to .setdeviceparams and let it sort things out.
  1407.    mark /HWResolution null /HWSize null /PageSize null .dicttomark
  1408.    .getdeviceparams .dicttomark begin
  1409.    mark
  1410.     % Check for resolution.
  1411.    /DEVICEXRESOLUTION where dup
  1412.     { exch pop HWResolution 0 DEVICEXRESOLUTION put }
  1413.    if
  1414.    /DEVICEYRESOLUTION where dup
  1415.     { exch pop HWResolution 1 DEVICEYRESOLUTION put }
  1416.    if
  1417.    or { /HWResolution HWResolution } if
  1418.     % Check for device sizes specified in pixels.
  1419.    /DEVICEWIDTH where dup
  1420.     { exch pop HWSize 0 DEVICEWIDTH put }
  1421.    if
  1422.    /DEVICEHEIGHT where dup
  1423.     { exch pop HWSize 1 DEVICEHEIGHT put }
  1424.    if
  1425.    or { /HWSize HWSize } if
  1426.     % Check for device sizes specified in points.
  1427.    /DEVICEWIDTHPOINTS where dup
  1428.     { exch pop PageSize 0 DEVICEWIDTHPOINTS put }
  1429.    if
  1430.    /DEVICEHEIGHTPOINTS where dup
  1431.     { exch pop PageSize 1 DEVICEHEIGHTPOINTS put }
  1432.    if
  1433.    or { /PageSize PageSize } if
  1434.     % Check whether any parameters were set.
  1435.    dup mark eq { pop } { defaultdevice putdeviceprops } ifelse
  1436.    end
  1437. %END DEVICE
  1438. % Set any device properties defined on the command line.
  1439. % If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace.
  1440. systemdict /BufferSpace known
  1441. systemdict /MaxBitmap known not and
  1442.  { systemdict /MaxBitmap BufferSpace put
  1443.  } if
  1444. dup getdeviceprops
  1445. counttomark 2 idiv
  1446.  { systemdict 2 index known
  1447.     { pop dup load counttomark 2 roll }
  1448.     { pop pop }
  1449.    ifelse
  1450.  } repeat
  1451. counttomark dup 0 ne
  1452.  { 2 add -1 roll putdeviceprops }
  1453.  { pop pop }
  1454. ifelse
  1455. % If the initial device parameters are invalid, the setdevice may fail.
  1456. % Trap this and produce a reasonable error message.
  1457. { setdevice }        % does an erasepage
  1458. DEBUG { exec false } { .internalstopped } ifelse {
  1459.   (**** Unable to open the initial device, quitting.) = 1 .quit
  1460. } if
  1461.  
  1462. % If the media size is fixed, update the current page device dictionary.
  1463. FIXEDMEDIA
  1464. dup { pop systemdict /.currentpagedevice known } if
  1465. dup { pop .currentpagedevice exch pop } if
  1466. not { (%END MEDIA) .skipeof } if
  1467. currentpagedevice dup length dict .copydict
  1468. dup /Policies
  1469.     % Stack: <pagedevice> <pagedevice> /Policies
  1470. 1 index /InputAttributes
  1471. 2 copy get dup length dict .copydict
  1472.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1473.     %   /InputAttributes <inputattrs'>
  1474. dup 0 2 copy get dup length dict .copydict
  1475.     % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1476.     %   /InputAttributes <inputattrs'> <inputattrs'> 0 <attrs0'>
  1477. dup /PageSize 7 index /PageSize get
  1478. put                % PageSize in 0
  1479. put                % 0 in InputAttributes
  1480. put                % InputAttributes in pagedevice
  1481. % Also change the page size policy so we don't get an error.
  1482.     % Stack: <pagedevice> <pagedevice> /Policies
  1483. 2 copy get dup length dict .copydict
  1484.     % Stack: <pagedevice> <pagedevice> /Policies <policies'>
  1485. dup /PageSize 7 put        % PageSize in Policies
  1486. put                % Policies in pagedevice
  1487. .setpagedevice
  1488. %END MEDIA
  1489. %END DISPLAYING
  1490.  
  1491. (END DEVICE) VMDEBUG
  1492.  
  1493. % Establish a default upper limit in the character cache,
  1494. % namely, enough room for a 18-point character at the resolution
  1495. % of the default device, or for a character consuming 1% of the
  1496. % maximum cache size, whichever is larger.
  1497. mark
  1498.     % Compute limit based on character size.
  1499.   18 dup dtransform
  1500.   exch abs cvi 31 add 32 idiv 4 mul    % X raster
  1501.   exch abs cvi mul        % Y
  1502.     % Compute limit based on allocated space.
  1503.   cachestatus pop pop pop pop pop exch pop 0.01 mul cvi
  1504.   .max dup 10 idiv exch
  1505. setcacheparams
  1506. % Conditionally disable the character cache.
  1507. NOCACHE { 0 setcachelimit } if
  1508.  
  1509. (END CONFIG) VMDEBUG
  1510.  
  1511. % Initialize graphics.
  1512.  
  1513. .setdefaultscreen
  1514. initgraphics
  1515.  
  1516. % The interpreter relies on there being at least 2 entries
  1517. % on the graphics stack.  Establish the second one now.
  1518. gsave
  1519.  
  1520. % Define some control sequences as no-ops.
  1521. % This is a hack to get around problems
  1522. % in some common PostScript-generating applications.
  1523. <04> cvn { } def        % Apple job separator
  1524. <0404> cvn { } def        % two of the same
  1525. <1b> cvn { } def        % MS Windows LaserJet 4 prologue
  1526.                 % (UEL = ESC %-12345X)
  1527. <1b45> cvn { } def        % PJL reset prologue (ESC E)
  1528. <1b451b> cvn { } def        % PJL reset epilogue (ESC E + UEL)
  1529. <041b> cvn { } def        % MS Windows LaserJet 4 epilogue (^D + UEL)
  1530. (\001M) cvn            % TBCP initiator
  1531.  { currentfile /TBCPDecode filter cvx exec
  1532.  } bind def
  1533. /@PJL                % H-P job control
  1534.  { currentfile //=string readline { pop } if
  1535.  } bind def
  1536.  
  1537. % If we want a "safer" system, disable some obvious ways to cause havoc.
  1538. SAFER not { (%END SAFER) .skipeof } if
  1539.  
  1540. .currentglobal true .setglobal
  1541. /SAFETY 1 dict dup /safe DELAYSAFER not put readonly def
  1542. .setglobal
  1543.  
  1544. /.setsafe
  1545.   { //SAFETY /safe //true .forceput % overrides readonly
  1546.   } .bind executeonly odef
  1547.  
  1548. /file
  1549.  { //SAFETY /safe get {
  1550.      dup (r) eq 2 index (%pipe*) .stringmatch not and
  1551.      2 index (%std*) .stringmatch or
  1552.        { file }
  1553.        { /invalidfileaccess //signalerror exec }
  1554.      ifelse
  1555.    } {
  1556.      file
  1557.    } ifelse
  1558.  } .bind executeonly odef
  1559.  
  1560. /renamefile
  1561.   { //SAFETY /safe get
  1562.       { /invalidfileaccess //signalerror exec }
  1563.       { renamefile }
  1564.     ifelse
  1565.   } .bind executeonly odef
  1566.  
  1567.  
  1568. /deletefile
  1569.   { //SAFETY /safe get
  1570.       { /invalidfileaccess //signalerror exec }
  1571.       { deletefile }
  1572.     ifelse
  1573.   } .bind executeonly odef
  1574.  
  1575. /putdeviceprops
  1576.  { //SAFETY /safe get { 
  1577.      counttomark
  1578.      dup 2 mod 0 eq { pop /rangecheck //signalerror exec } if
  1579.      3 2 3 2 roll
  1580.       { dup index /OutputFile eq  
  1581.          { -2 roll 
  1582.            dup () ne
  1583.              { /putdeviceprops load /invalidfileaccess //signalerror exec
  1584.              } if
  1585.          3 -1 roll
  1586.          }
  1587.          { pop
  1588.          }
  1589.         ifelse
  1590.       } for
  1591.      putdeviceprops
  1592.    } {
  1593.      putdeviceprops
  1594.    } ifelse
  1595.  } .bind executeonly odef
  1596.  
  1597. currentdict /SAFETY undef
  1598.  
  1599. %END SAFER
  1600.  
  1601. % If we delayed binding, make it possible to do it later.
  1602. /.bindnow {
  1603.   //systemdict begin .bindoperators end
  1604.   % Temporarily disable the typecheck error.
  1605.   errordict /typecheck 2 copy get
  1606.   errordict /typecheck { pop } put    % pop the command
  1607.   0 1 .delaycount 1 sub { .delaybind exch get .bind pop } for
  1608.   //systemdict /.delaybind {} .forceput    % reclaim the space
  1609.   //systemdict /.bindnow .forceundef    % ditto
  1610.   put
  1611.   //systemdict /.forcedef .forceundef        % remove temptation
  1612.   //systemdict /.forceput .forceundef        % ditto
  1613.   //systemdict /.forceundef .forceundef        % ditto
  1614. } .bind odef
  1615.  
  1616. % Turn off array packing, since some PostScript code assumes that
  1617. % procedures are writable.
  1618. false setpacking
  1619.  
  1620. (END INIT) VMDEBUG
  1621.  
  1622. /.currentuserparams where {
  1623.   pop
  1624.     % Remove real user params from psuserparams.
  1625.   mark .currentuserparams counttomark 2 idiv {
  1626.     pop psuserparams exch undef
  1627.   } repeat pop
  1628.     % Update the copy of the user parameters.
  1629.   mark .currentuserparams counttomark 2 idiv {
  1630.     userparams 3 1 roll .forceput    % userparams is read-only
  1631.   } repeat pop
  1632.     % Turn on idiom recognition, if available.
  1633.   currentuserparams /IdiomRecognition known {
  1634.     /IdiomRecognition true .definepsuserparam
  1635.   } if
  1636.   psuserparams readonly pop
  1637.   systemdict /.definepsuserparam undef
  1638.     % Save a copy of userparams for use with save/restore
  1639.     % (and, if implemented, context switching).
  1640.   .currentglobal false .setglobal
  1641.      mark userparams { } forall .dicttomark readonly
  1642.      /userparams exch .forcedef        % systemdict is read-only
  1643.   .setglobal
  1644. } if
  1645. /.currentsystemparams where {
  1646.   pop
  1647.     % Remove real system params from pssystemparams.
  1648.   mark .currentsystemparams counttomark 2 idiv {
  1649.     pop pssystemparams exch .forceundef
  1650.   } repeat pop
  1651. } if
  1652.  
  1653. % Conditionally turn image interpolation on or off.
  1654. currentdict /INTERPOLATE known not { (%END INTERPOLATE) .skipeof } if
  1655.  
  1656. /.interpolate {
  1657.   dup /Interpolate .knownget not { //false } if
  1658.   /INTERPOLATE .systemvar ne {
  1659.     dup gcheck .currentglobal exch .setglobal
  1660.     exch dup length dict copy
  1661.     dup /Interpolate /INTERPOLATE .systemvar put
  1662.     exch .setglobal
  1663.   } if
  1664. } bind odef
  1665.  
  1666. /colorimage
  1667.   { /INTERPOLATE .systemvar
  1668.       { .currentglobal                    % w h bit [] {}...{} multi ncomp glob
  1669.         //false .setglobal
  1670.         9 dict begin                      % w h bit [] {}...{} multi ncomp glob
  1671.         2 index { 1 index 7 add } { 8 } ifelse
  1672.         copy gsave pop                    % preserve the arguments
  1673.         { 0 /DeviceGray 0 /DeviceRGB /DeviceCMYK }
  1674.         1 index get setcolorspace         % ... glob w h bit [] {}...{} multi ncomp
  1675.         {0 1 0 1 0 1 0 1}
  1676.         1 index 2 mul 0 exch              % ... glob w h bit [] {}...{} multi ncomp {0 1 ...} 0 2*ncomp
  1677.         getinterval /Decode exch def      % ... glob w h bit [] {}...{} multi ncomp
  1678.         exch dup                          % ... glob w h bit [] {}...{} ncomp multi multi
  1679.         /MultipleDataSources exch def     % ... glob w h bit [] {}...{} ncomp multi
  1680.         { array astore} { pop } ifelse    % ... glob w h bit [] [{}...{}]
  1681.         /DataSource exch def              % ... glob w h bit []
  1682.         /ImageMatrix exch def             % ... glob w h bit
  1683.         /BitsPerComponent exch def        % ... glob w h
  1684.         /Height exch def                  % ... glob w
  1685.         /Width exch def                   % ... glob 
  1686.         /ImageType 1 def
  1687.         /Interpolate //true def
  1688.         .setglobal currentdict end        % ... <<>>
  1689.         image grestore
  1690.         exch { 4 add } { 6 } ifelse
  1691.         { pop } repeat                    % -
  1692.       }
  1693.       { colorimage
  1694.       }
  1695.     ifelse
  1696.   } bind odef
  1697.  
  1698. /image
  1699.   { dup type /dicttype eq
  1700.       { dup /ImageType get 3 eq
  1701.           { .currentglobal //false .setglobal exch
  1702.             dup length dict copy begin .setglobal 
  1703.             /DataDict DataDict .interpolate def
  1704.             /MaskDict MaskDict .interpolate def
  1705.             currentdict end
  1706.           }
  1707.           { .interpolate 
  1708.           }
  1709.         ifelse
  1710.         image
  1711.       }
  1712.       { /INTERPOLATE .systemvar
  1713.           { .currentglobal //false .setglobal
  1714.             8 dict begin .setglobal
  1715.             /ImageType 1 def
  1716.             /DataSource 1 index def
  1717.             /ImageMatrix 2 index def
  1718.             /BitsPerComponent 3 index def
  1719.             /Decode {0 1} def
  1720.             /Height 4 index def
  1721.             /Width 5 index def
  1722.             /Interpolate //true def
  1723.             currentdict end
  1724.             gsave /DeviceGray setcolorspace image grestore
  1725.             5 { pop } repeat
  1726.           }
  1727.           { image
  1728.           }
  1729.         ifelse
  1730.       }
  1731.     ifelse
  1732.   } bind odef
  1733.  
  1734. /imagemask {
  1735.   dup type /dicttype eq {
  1736.     .interpolate imagemask
  1737.   } {
  1738.     /INTERPOLATE .systemvar {
  1739.       .currentglobal //false .setglobal
  1740.       8 dict begin .setglobal
  1741.       /ImageType 1 def
  1742.       /DataSource 1 index def
  1743.       /ImageMatrix 2 index def
  1744.       /BitsPerComponent 1 def
  1745.       2 index { {1 0} } { {0 1} } ifelse /Decode exch def
  1746.       /Height 4 index def
  1747.       /Width 5 index def
  1748.       /Interpolate //true def
  1749.       currentdict end imagemask 5 { pop } repeat
  1750.     } {
  1751.       imagemask
  1752.     } ifelse
  1753.   } ifelse
  1754. } bind odef
  1755.  
  1756. currentdict /.interpolate undef
  1757.  
  1758. %END INTERPOLATE
  1759.  
  1760. % Establish local VM as the default.
  1761. false /setglobal where { pop setglobal } { .setglobal } ifelse
  1762. $error /.nosetlocal false put
  1763.  
  1764. (END GLOBAL) VMDEBUG
  1765.  
  1766. /.savelocalstate where {
  1767.     % If we might create new contexts, save away copies of all dictionaries
  1768.     % referenced from systemdict that are stored in local VM,
  1769.     % and also save a copy of the initial gstate.
  1770.   pop .savelocalstate
  1771. } {
  1772.     % If we're *not* running in a multi-context system and FAKEFONTS is
  1773.     % defined, add the fake fonts to LocalFontDirectory.
  1774.   .definefakefonts    % current VM is local
  1775. } ifelse
  1776.  
  1777. % Remove systemdict entries for things that have been bound in where used
  1778. % and that shouldn't be accessible by name, and close up systemdict.
  1779. currentdict /filterdict .undef
  1780. currentdict /.cidfonttypes .undef
  1781. currentdict /.colorrenderingtypes .undef
  1782. currentdict /.formtypes .undef
  1783. currentdict /.halftonetypes .undef
  1784. currentdict /.imagetypes .undef
  1785. currentdict /.imagemasktypes .undef
  1786. currentdict /.patterntypes .undef
  1787. currentdict /.shadingtypes .undef
  1788. currentdict /.wheredict .undef
  1789. end
  1790.  
  1791. % Clean up VM, and enable GC.
  1792. /vmreclaim where
  1793.  { pop NOGC not { 2 vmreclaim 0 vmreclaim } if
  1794.  } if
  1795. DELAYBIND not {
  1796.   systemdict /.forcedef .undef        % remove temptation
  1797.   systemdict /.forceput .undef        % ditto
  1798.   systemdict /.forceundef .undef    % ditto
  1799. } if
  1800. WRITESYSTEMDICT not { systemdict readonly pop } if
  1801.  
  1802. (END GC) VMDEBUG
  1803.  
  1804. % The interpreter will run the initial procedure (start).
  1805.